<form class="layui-form" action="">
         <div class="layui-form-item">
                <label class="layui-form-label">主键编号</label>
                <div class="layui-input-block">
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">教室证号</label>
                <div class="layui-input-block">
                    <input type="text" name="teacherId" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">课程名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">上课开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="toClasstime" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">上课结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="goClasstime" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">课程时间</label>
                <div class="layui-input-block">
                    <select name="sate" lay-filter="aihao">
                        <option value="0">上午</option>
                        <option value="1">下午</option>
                    </select>
                </div>
           </div>
         <div class="layui-form-item">
                <label class="layui-form-label">班级</label>
                <div class="layui-input-block">
                    <input type="text" name="cclass" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
           </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(["jquery","form"],function () {
        layui.use('form', function(){
            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            form.render();
        });
        var $=layui.jquery
        ,form=layui.form;

        form.on('submit(demo1)', function(data){//点击提交按钮
           $.ajax({
               url:"/course/addCourse",
               data:data.field,
               dataType:"json",
               type:"post",
               success:function (msg) {
                   if (msg.code==0){
                        tableIns.reload({
                            page:{
                                curr:1
                            }
                        });
                        layer.msg(msg.msg);//提示后台传过来的信息
                        layer.close(openIndex);//关闭当前弹出的窗体
                   }else{
                       layer.msg(msg.msg);//提示后台传过来的信息
                   }
               }
           });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>